package com.ruoyi.basebill.task;

/*
 * @Author xiefeng
 * @Date 2023/4/10 15:05
 * @Description 将下推单据、汇总单据和推送eas组合成一个定时任务
 * @Since version-1.0
 */

import com.ruoyi.basebill.domain.OmsDeliverbill;
import com.ruoyi.basebill.task.util.OmsTaskUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("OmsPushBillAllTask")
public class OmsPushBillAllTask {
    //发货确认接口
    @Autowired
    private OmsDeliverbillTask omsDeliverbillTask;
    //收货确认接口
    @Autowired
    private OmsReceiptBillTask omsReceiptBillTask;
    //收货确认接口
    @Autowired
    private OmsReceiptBillTaskNew omsReceiptBillTaskNew;
    //销售退货接口
    @Autowired
    private PushSaleIssueTask pushSaleIssueTask;
    //调拨单接口
    @Autowired
    private OmsTransferbillTask omsTransferbillTask;
    //汇总销出单接口
    @Autowired
    private OmsSumSaleIssueBillTask omsSumSaleIssueBillTask;
    //汇总采入单接口
    @Autowired
    private OmsSumPurInWarehsBillTask omsSumPurInWarehsBillTask;
    //汇总库存调拨单接口
    @Autowired
    private OmsSumStockTransferBillTask omsSumStockTransferBillTask;
    //推送eas接口
    @Autowired
    private PushEASBillDataTask pushEASBillDataTask;
    //工具类型对象
    @Autowired
    private OmsTaskUtil omsTaskUtil;



    /**
     * 下推所有单据类型的数据并汇总推送eas
     */
    public void allPushBillTaskMethod(){
        //下推之前，先将重复单据处理一遍，防止出现重复单据重复下发
        omsTaskUtil.dealAllRepeatBill();
        /*
         * 下推内部单据
         */
        //执行发货确认下推单据
        omsDeliverbillTask.pushDown();
        //执行收货确认下推单据
        omsReceiptBillTaskNew.pushDown();
        //执行销退下推单据
        pushSaleIssueTask.pushSaleIssueTask();
        //执行调拨单下推单据
        omsTransferbillTask.pushDown();
        /*
         * 汇总内部单据
         */
        //汇总销出单
        omsSumSaleIssueBillTask.summary();
        //汇总采入单
        omsSumPurInWarehsBillTask.summary();
        //汇总库存调拨单
        omsSumStockTransferBillTask.summary();
        /*
         * 推送eas
         */
        //汇总采入单推送eas
        pushEASBillDataTask.pushSumPurInWarehsBill();
        //汇总销出单推送eas
        pushEASBillDataTask.pushSumSaleIssueBill();
        //汇总库存调拨单推送eas
        pushEASBillDataTask.pushSumStockTransferBill();

    }

    /**
     * 下推调拨单并汇总推送eas
     */
    public void pushTransBillAllTask(){
        omsTaskUtil.dealRepeatTransferbill();
        /*
         * 下推调拨单
         */
        //执行调拨单下推单据
        omsTransferbillTask.pushDown();
        /*
         * 汇总内部单据
         */
        //汇总销出单
        omsSumSaleIssueBillTask.summary();
        //汇总采入单
        omsSumPurInWarehsBillTask.summary();
        //汇总库存调拨单
        omsSumStockTransferBillTask.summary();
        /*
         * 推送eas
         */
        //汇总采入单推送eas
        pushEASBillDataTask.pushSumPurInWarehsBill();
        //汇总销出单推送eas
        pushEASBillDataTask.pushSumSaleIssueBill();
        //汇总库存调拨单推送eas
        pushEASBillDataTask.pushSumStockTransferBill();
    }


    /**
     * 下推早餐销售退货数据并汇总推送eas
     */
    public void pushZCSaleReturnBillAllTask(){
        omsTaskUtil.dealRepeatSalereturnbill();
        //执行早餐销售退货下发
        pushSaleIssueTask.pushSaleIssueTaskZC();
        /*
         * 汇总内部单据
         */
        //汇总销出单
        omsSumSaleIssueBillTask.summary();
        //汇总采入单
        omsSumPurInWarehsBillTask.summary();
        //汇总库存调拨单
        omsSumStockTransferBillTask.summary();
        /*
         * 推送eas
         */
        //推送对外销出单
        pushEASBillDataTask.pushSaleIssueBill();
        //推送其他出库单
        pushEASBillDataTask.pushOtherIssueBill();
        //汇总采入单推送eas
        pushEASBillDataTask.pushSumPurInWarehsBill();
        //汇总销出单推送eas
        pushEASBillDataTask.pushSumSaleIssueBill();
        //汇总库存调拨单推送eas
        pushEASBillDataTask.pushSumStockTransferBill();
    }

}
